//
//  Canvas.m
//  costa-postcards
//
//  Created by 黄 鹏霄 on 12-12-14.
//  Copyright (c) 2012年 test. All rights reserved.
//

#import "Canvas.h"

@implementation Canvas
@synthesize delegate =_delegate;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor redColor];
        [self setClipsToBounds:YES];
        
        UIButton *flipButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [flipButton setTitle:@"flip" forState:UIControlStateNormal];
        flipButton.frame = CGRectMake(self.frame.size.width - 34, self.frame.size.height - 34, 44, 44);
        [flipButton addTarget:self action:@selector(flip:) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:flipButton];
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

#pragma mark - 

-(void)flip:(UIButton *)sender
{
    [[self delegate]willCanvasFlip:sender];
}

@end
